#region Copyright
/// <copyright>
/// Copyright (c) 2007 Ilia Shramko.
/// Released under the terms of the GNU General Public License.
/// </copyright>
#endregion

using System;
using System.Collections.Generic;
using System.Text;

namespace Osh.Teletext
{
	public class EnhancementDataPacket : NonDisplayablePacket
	{
		public const int MaxTripletNumber = 13;

		private int[] _triplets;

		public EnhancementDataPacket(int magazine, int packet, byte[] data, int position)
			: base(magazine, packet, TeletextDecoder.DecodeDesignationCode(data, position))
		{
			position++; // skip designation code

			_triplets = new int[MaxTripletNumber];
			for(int i = 0; i < MaxTripletNumber; i++)
			{
				_triplets[i] = HummingDecoder.Decode2418(data, position + i*3);
			}
		}

		/// <summary>
		/// Returns enhancement packet triplet.
		/// </summary>
		/// <param name="index">Triplet index from 0 to 12.</param>
		/// <returns></returns>
		public int GetTriplet(int index)
		{
			return _triplets[index];
		}
	}
}
